home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group00b.txt / 000141_icon-group-sender_Fri Nov 3 07:43:22 2000.msg < prev    next >
Internet Message Format  |  2001-01-03  |  3KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id eA3Eg3A27420
  4.     for icon-group-addresses; Fri, 3 Nov 2000 07:42:03 -0700 (MST)
  5. Message-Id: <200011031442.eA3Eg3A27420@baskerville.CS.Arizona.EDU>
  6. Date: Thu, 02 Nov 2000 19:49:30 -0600
  7. From: gep2@terabites.com
  8. Subject: Re: How to "declare" a string?
  9. To: icon-group@cs.arizona.edu
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11. Status: RO
  12. Content-Length: 1970
  13.  
  14. >> best I can tell, it is choking because UPPER has not been "declared".
  15.  
  16. > I am a *total* newbie, but I may have an answer to this one
  17. (Icon programmer please correct this if wrong)
  18. Icon will extract as much information from your statements as possible.
  19.  
  20. > so, if you initialize a variable like this:
  21.  
  22. > i := 0
  23.  
  24. > it will not need an
  25.  
  26. > i : INTEGER to figure it out, it knows that 0 is an integer, and will declare 
  27. i implicitely.
  28.  
  29. Not really.  There is no "declaring" that i IS an integer (in any lasting 
  30. sense!).  In fact i is simply a variable and it can contain an integer at one 
  31. moment, a string the next and a real at some later time.  There is no durable 
  32. typing of any user-defined variables in Icon.
  33.  
  34. That said, Icon *does* keep careful track of what type each variable contains at 
  35. any given instant, so that it can be converted as necessary for whatever 
  36. operation might require that.
  37.  
  38. > the same with a string:
  39.  
  40. > s := ""
  41.  
  42. > will implicitely declare s to be string type.
  43.  
  44. Again, it merely tells Icon that *now* the variable s happens to contain a 
  45. string.  You can subsequently execute:
  46.  
  47.   s := "435" + 27.2 + 6 + '12'
  48.  
  49. (adding a string, a real, an integer and a character set variable) and the 
  50. result will be that the variable s will now contain a real.
  51.  
  52. > If in the start of your program, you set
  53.  
  54. > UPPER := ""
  55.  
  56. > you might solve an 'undeclared' reference ...
  57.  
  58. No.  All variables default (in the absence of a prior declaration to the 
  59. contrary in some specific situations like the unassigned elements of tables 
  60. where I think you can specify a different default) to be a null string.  Since 
  61. that is the default value, assigning it a (redundant) null string as the value 
  62. won't change anything.
  63.  
  64. Gordon Peterson
  65. http://personal.terabites.com/
  66. Support the Anti-SPAM Amendment!  Join at http://www.cauce.org/
  67. 12/19/98: the day the Conservatives demonstrated their scorn for their
  68.    fraudulent sham of representative government.  Voters, remember it!
  69.  
  70.